package com.macro.mall.common.exception;

import com.macro.mall.common.api.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;

/**
 * @ClassName GlobalExceptionHandler
 * @Description 全局异常处理
 * @Author lin.dai
 * @Version 1.0
 **/
@ControllerAdvice
public class GlobalExceptionHandler {
    public CommonResult handle(ApiException e){
        if(e.getErrorCode() != null){
            return CommonResult.failed(e.getErrorCode());
        }
        return CommonResult.failed(e.getMessage());
    }
}
